﻿using DBUtility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WeChat.Models;

namespace WeChat.Controllers
{
    public class HomeController : Controller
    {

        DbHelper helper = new DbHelper("3");
        log4net.ILog logger = log4net.LogManager.GetLogger("WeChatConnect");
        public ActionResult Index()
        {
            logger.Info("首页Index:"+DateTime.Now.ToString());
            return View();
        }

        public ActionResult About()
        {
            ViewBag.Message = "Your application description page.";

            return View();
        }

        [HttpPost]
        public ActionResult CheckLogin(string username, string pwd)
        {
            logger.Info("登录CheckLogin-用户名:" + username + "密码：" + pwd);
            return Content(new AjaxResult { state = ResultType.success.ToString(), message = "登录成功" }.ToJson());
        }

        public ActionResult Contact()
        {
            ViewBag.Message = "Your contact page.";

            return View();
        }

        public ActionResult Register()
        {
            logger.Info("进入注册页面--" + "时间:" + DateTime.Now.ToString());
            return View();
        }


        [HttpPost]
        public ActionResult Register(string username, string pwd)
        {
            logger.Info("注册Register-用户名:" + username + "密码：" + pwd + "时间:" + DateTime.Now.ToString());
            return Content(new AjaxResult { state = ResultType.success.ToString(), message = "注册成功" }.ToJson());
        }

        public ActionResult UserInfo()
        {
            logger.Info("进入个人中心页面:"+DateTime.Now.ToString());
            return View();
        }

        public ActionResult TestCon()
        {
            string userSql = string.Format(@"select * from base_user");
            var userQuery = helper.GetDataSet(userSql);
            return View();
        }

        public ActionResult Error404()
        {
            return View();
        }
    }
}